class UserManager {
    // 静态属性存储用户信息
    static userid = null;
    static username = null;

    // 静态方法，用于设置用户信息
    static setUser(id, name) {
        this.userid = id;
        this.username = name;
    }

    static getUserid() {
        return this.userid;
    }

    static getUsername() {
        return this.username;
    }

    static loadUser() {
        const user = localStorage.getItem('currentUser');
        if (user) {
            const {userid, username} = JSON.parse(user);
            this.userid = userid;
            this.username = username;
        }
    }

    static saveUser() {
        if (this.userid && this.username) {
            localStorage.setItem('currentUser', JSON.stringify({
                userid: this.userid,
                username: this.username
            }));
        }
    }

// 登出时清除
    static logout() {
        this.userid = null;
        this.username = null;
        localStorage.removeItem('currentUser');
    }
}
